package com.fight.strive.sys.modules.rbac.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.fight.strive.sys.modules.common.PageR;
import com.fight.strive.sys.modules.rbac.dto.RbacDepartmentTreeDto;
import com.fight.strive.sys.modules.rbac.entity.RbacDepartmentEntity;
import com.fight.strive.sys.modules.redis.CacheInterface;
import com.fight.strive.sys.modules.validator.StriveValid;

import java.util.List;

public interface RbacDepartmentService
        extends IService<RbacDepartmentEntity>, CacheInterface<RbacDepartmentEntity> {

    /**
     * 保存部门
     *
     * @param entity entity
     */
    void saveDepartment(@StriveValid RbacDepartmentEntity entity);

    /**
     * 根据ID获取部门，有缓存
     *
     * @param id id
     * @return entity
     */
    RbacDepartmentEntity getDeparmentById(Long id);

    /**
     * 分页查询部门列表
     *
     * @param page page
     * @return ipage
     */
    IPage<RbacDepartmentEntity> listByPage(PageR<RbacDepartmentEntity> page);

    /**
     * 获取子部门列表
     *
     * @param parentId parentId
     * @return entity
     */
    List<RbacDepartmentEntity> listDepartmentsByParentId(Long parentId);

    /**
     * 获取部门结构树
     *
     * @param parentId 父部门ID，如果parentId为空，则为0，顶层部门
     * @return list tree node
     */
    List<RbacDepartmentTreeDto> getDepartmentTree(Long parentId);

    /**
     * 根据ID删除部门
     *
     * @param id id
     */
    void removeDepartment(Long id);
}
